import axios from '@/utils/request'

// 获取文章详情的接口
export const getArticleInfo = id => {
  return axios.get('/v1_0/articles/' + id)
}

// 关注文章的作者
export const followUser = authorId => {
  return axios.post('/v1_0/user/followings', {
    target: authorId
  })
}

// 取消关注文章作者
export const unfollowUser = authorId => {
  return axios.delete('/v1_0/user/followings/' + authorId)
}

// 获取文章下的评论数据
export const getCmtByArtId = (artId, offset) => {
  return axios.get('/v1_0/comments', {
    params: {
      type: 'a',
      source: artId,
      offset
    }
  })
}

// 为文章的评论点赞
export const addCmtLike = cmtId => {
  return axios.post('/v1_0/comment/likings', {
    target: cmtId
  })
}

// 为文章发布新评论
export const pubCmt = (artId, content) => {
  return axios.post('/v1_0/comments', {
    target: artId,
    content
  })
}
